package com.example.pinkcat.adapter;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.pinkcat.R;
import com.example.pinkcat.activity.VideoActivity;
import com.example.pinkcat.activity.ViewAllMyFollow;
import com.example.pinkcat.activity.api.entity.VideoEntity;
import com.example.pinkcat.api.entity.VideowaibuEntity;
import com.example.pinkcat.fragment.shouye.Fragment_yingshi;
import com.rishabhharit.roundedimageview.RoundedImageView;
import com.example.pinkcat.api.entity.myCollectStaticMsg;

import java.util.ArrayList;
import java.util.List;

public class Yingshi_2_RecyclerViewAdapter extends RecyclerView.Adapter<Yingshi_2_RecyclerViewAdapter.ViewHolder> {

    private Context context;

    List<VideoEntity> videoEntities= new ArrayList<>();


    public Yingshi_2_RecyclerViewAdapter(Context context){
        this.context = context;
    }

    public void setData(List<VideoEntity> videoEntities){
        this.videoEntities = videoEntities;
        notifyDataSetChanged();
    }

    public class ViewHolder extends RecyclerView.ViewHolder{
        public RoundedImageView imageView_big;
        public TextView textViewDescription_big;
        public TextView textViewTitlte_big;

        public View list_video;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            imageView_big=itemView.findViewById(R.id.lis_manga_img_big);
            textViewTitlte_big=itemView.findViewById(R.id.manga_title_big);
            textViewDescription_big=itemView.findViewById(R.id.manga_descrptioon_big);

            list_video = itemView.findViewById(R.id.yingshi_list_video);
        }
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

        View view;
        view= LayoutInflater.from(context).inflate(R.layout.layout_manga_ys_zf,parent,false);

        return new Yingshi_2_RecyclerViewAdapter.ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {

        holder.textViewTitlte_big.setText(String.valueOf(videoEntities.get(position).getVideo_name()));//预设标题
        Glide.with(context).load(Uri.parse(videoEntities.get(position).getVideo_cover())).into(holder.imageView_big);//预设图片


        holder.list_video.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(context, VideoActivity.class);
                intent.putExtra("v_id",videoEntities.get(position).getVideo_id());
                intent.putExtra("up_id",videoEntities.get(position).getUser_id());
                intent.putExtra("v_link",videoEntities.get(position).getVideo_link());
                intent.putExtra("v_labs",videoEntities.get(position).getVideo_lab());
                context.startActivity(intent);
            }
        });

    }


    @Override
    public int getItemCount() {

        return videoEntities.size();
    }


}
